package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception{

        Class cls = Class.forName("reflect.Person");
        Constructor con = cls.getConstructor(String.class,int.class);
        Object obj = con.newInstance("王五", 20);
        System.out.println(obj);
        Method method = cls.getMethod("watchTV");
        Object obj1 =method.invoke(obj);

    }
}
